package com.aspose.cells;

class zawg extends zawf {
   private zagu[] a;
   private int b;
   private zagu c;
   private int d;
   private boolean e;
   private boolean f;
   private boolean g;
   private int h;
   private int i;
   private int j;
   private int k;
   private boolean l;
   private boolean m;
   private int n;
   private zagu o;

   public zawg(zagu[] var1) {
      this(var1, false, 0, var1.length, 6, zzk.a, 0, false);
   }

   public zawg(zagu[] var1, boolean var2, int var3, int var4, int var5, zagu var6, int var7, boolean var8) {
      this.a = var1;
      this.b = var5;
      this.c = var6;
      this.f = var2;
      this.g = var8;
      this.d = var4;
      this.e = this.d < 2;
      this.i = var3;
      this.h = var7;
      this.E();
   }

   zawg(zawg var1) {
      this.a = var1.a;
      this.b = var1.b;
      this.c = var1.c;
      this.d = var1.d;
      this.e = var1.e;
      this.f = var1.f;
      this.g = var1.g;
      this.h = var1.h;
      this.i = var1.i;
      this.j = var1.j;
      this.k = var1.k;
      this.l = var1.l;
      this.m = var1.m;
      this.n = var1.n;
      this.o = var1.o;
   }

   public zahn b(zaay var1) {
      return new zawg(this);
   }

   public int c() {
      return this.f ? this.d : 1;
   }

   public int d() {
      return this.f ? 1 : this.d;
   }

   public int e() {
      return this.d;
   }

   public boolean l() {
      return this.e;
   }

   public boolean m() {
      return !this.f;
   }

   public boolean n() {
      return this.f;
   }

   public int b() {
      return this.b;
   }

   public zagu a(int var1, int var2) {
      if (this.e) {
         return this.o;
      } else if (this.m) {
         return this.c;
      } else {
         if (this.f) {
            var1 += this.i;
            if (var1 >= this.j && var1 <= this.k) {
               return this.a[var1];
            }
         } else {
            var2 += this.i;
            if (var2 >= this.j && var2 <= this.k) {
               return this.a[var2];
            }
         }

         return this.c;
      }
   }

   public void f() {
      if (!this.e && !this.m) {
         this.n = this.j - 1;
      }
   }

   public boolean b(int var1, int var2) {
      return !this.e && !this.m ? this.a(this.f ? var1 : var2) : false;
   }

   public boolean a(int var1) {
      if (!this.e && !this.m) {
         var1 += this.i;
         if (var1 <= this.j) {
            if (this.l) {
               this.n = this.j;
               this.o = this.a[this.n];
               return true;
            }

            if (this.n == this.j) {
               return true;
            }

            this.n = this.j - 1;
         } else {
            if (var1 == this.n) {
               return this.n <= this.k;
            }

            if (var1 > this.k) {
               this.n = this.k + 1;
               return false;
            }

            this.n = var1 - 1;
         }

         return this.g();
      } else {
         return false;
      }
   }

   public boolean g() {
      if (!this.e && !this.m) {
         ++this.n;
         if (this.n > this.k) {
            return false;
         } else {
            this.o = this.a[this.n];
            if (!a(this.o, this.c)) {
               return true;
            } else {
               do {
                  ++this.n;
                  if (this.n > this.k) {
                     return false;
                  }

                  this.o = this.a[this.n];
               } while(a(this.o, this.c));

               return true;
            }
         }
      } else {
         return false;
      }
   }

   public zagu h() {
      if (this.o.b() == 13) {
         zzh var1 = (zzh)this.o;
         if (var1.k().c() == 2) {
            this.o = var1.k().n();
            this.a[this.n] = this.o;
         }
      }

      return this.o;
   }

   public int i() {
      return this.f ? this.n - this.i : 0;
   }

   public int j() {
      return this.f ? 0 : this.n - this.i;
   }

   public int k() {
      return this.n - this.i;
   }

   public zahn b(int var1) {
      if (!this.f) {
         return this;
      } else {
         var1 += this.i;
         zagu var2;
         if (var1 >= this.j && var1 <= this.k) {
            var2 = this.a[var1];
         } else {
            var2 = this.c;
         }

         return new zaya(var2, this.b);
      }
   }

   public zahn c(int var1) {
      if (this.f) {
         return this;
      } else {
         var1 += this.i;
         zagu var2;
         if (var1 >= this.j && var1 <= this.k) {
            var2 = this.a[var1];
         } else {
            var2 = this.c;
         }

         return new zaya(var2, this.b);
      }
   }

   public boolean a(zagu var1) {
      return a(var1, this.e ? this.o : this.c);
   }

   public zagu o() {
      return this.e ? this.o : this.c;
   }

   public boolean x() {
      return this.g && this.f;
   }

   public boolean y() {
      return this.g && !this.f;
   }

   public void a(zaay var1) {
      if (this.g) {
         if (this.f) {
            if (var1.g == this.h) {
               return;
            }

            this.i += var1.g - this.h;
            this.h = var1.g;
         } else {
            if (var1.h == this.h) {
               return;
            }

            this.i += var1.h - this.h;
            this.h = var1.h;
         }

         this.E();
      }
   }

   public boolean q() {
      return this.l;
   }

   public int r() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : (this.f ? this.j - this.i : 0);
   }

   public int s() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : (this.f ? this.k - this.i : 0);
   }

   public int t() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : (this.f ? 0 : this.j - this.i);
   }

   public int u() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : (this.f ? 0 : this.k - this.i);
   }

   public int v() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : this.j;
   }

   public int w() {
      if (!this.l) {
         this.C();
      }

      return this.m ? -1 : this.k;
   }

   public boolean a(zaay var1, int[] var2) {
      if (this.b(var1, var2)) {
         if (this.f) {
            var2[2] = var2[1];
            var2[1] = 0;
            var2[3] = 0;
         } else {
            var2[3] = var2[1];
            var2[1] = var2[0];
            var2[0] = 0;
            var2[2] = 0;
         }

         return true;
      } else {
         return false;
      }
   }

   public boolean b(zaay var1, int[] var2) {
      if (!this.g) {
         if (!this.l) {
            this.C();
         }

         if (this.m) {
            return false;
         } else {
            var2[0] = this.j - this.i;
            var2[1] = this.k - this.i;
            return true;
         }
      } else {
         int var3 = Math.min(this.a.length, this.i + this.d + (this.f ? var1.l.EndRow : var1.l.EndColumn) - this.h);
         int var4 = this.i + (this.f ? var1.l.StartRow : var1.l.StartColumn) - this.h;

         for(int var5 = Math.max(0, var4); var5 < var3; ++var5) {
            if (!a(this.a[var5], this.c)) {
               var2[0] = var5 - var4;
               --var3;
               if (var5 >= var3) {
                  var2[1] = var5 - var4;
                  return true;
               }

               while(a(this.a[var3], this.c)) {
                  --var3;
                  if (var3 == var5) {
                     var2[1] = var5 - var4;
                     return true;
                  }
               }

               var2[1] = var3 - var4;
               return true;
            }
         }

         return false;
      }
   }

   private void C() {
      this.l = true;

      while(true) {
         if (!a(this.a[this.j], this.c)) {
            if (this.j < this.k) {
               do {
                  if (!a(this.a[this.k], this.c)) {
                     return;
                  }

                  --this.k;
               } while(this.j != this.k);

               this.o = this.a[this.j];
               break;
            }

            this.o = this.a[this.j];
            break;
         }

         ++this.j;
         if (this.j > this.k) {
            this.D();
            break;
         }
      }

   }

   private void D() {
      this.m = true;
      this.j = -1;
      this.k = -1;
   }

   private void E() {
      this.n = this.i - 1;
      this.l = false;
      this.m = false;
      if (this.i < this.a.length && this.i > -this.d) {
         if (!this.e && this.i != this.a.length - 1) {
            if (this.i + this.d == 1) {
               this.n = 0;
            }
         } else {
            this.n = this.i;
         }

         if (this.n >= this.i) {
            this.l = true;
            this.o = this.a[this.n];
            if (a(this.o, this.c)) {
               this.D();
            } else {
               this.j = this.n;
               this.k = this.n;
            }
         } else {
            this.j = Math.max(0, this.i);
            this.k = Math.min(this.a.length, this.i + this.d) - 1;
         }
      } else {
         this.l = true;
         this.D();
      }

   }
}
